﻿using UnityEngine;
using System.Collections;

public class infinitItem : MonoBehaviour {

	public GameObject[] items = new GameObject[3];
	//public float infinitcoinmin = 0f;
	//public float infinitcoinmax = 1f;
	public float spawnRate = 3.0f;
	private Vector3 Cameralocation = new Vector3(0,0,0);

	// Use this for initialization
	void Start () {
		//Delay para nao instanciar toda a vez que se faz o update.
		InvokeRepeating("infinity",6.0f,spawnRate);
	}
	
	//Update is called once per frame

	void SetTransformX(float n){
		
		Cameralocation = new Vector3(transform.position.x + n, -427 , 0);

	}
	void infinity () {
		//transform.position = 0;
		SetTransformX(Random.Range(200,-200));
		//Cameralocation = new Vector3(transform.position.x, transform.position.y, transform.position.z);
		Instantiate (items[Random.Range (0, 3)],Cameralocation , transform.rotation);
		//Invoke ("infinity", Random.Range (infinitcoinmin, infinitcoinmax));


	}





}
